<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<script type="text/javascript">
    $(function () {
        var html="";
        var userHtml="";
        var userId='<shiro:principal property="id"/>';
        <c:forEach items="${workPlan.workCommentOpinionList}" var="opinion">
            var commentator='${opinion.commentator}';
            if(userId!=commentator){
                if(${opinion.commentTime!=null}){
                    html+="<p><b>${opinion.commentatorName}</b>&nbsp;&nbsp;&nbsp;"+datetime2Str('${opinion.commentTime}')+"</p>";
                    html+="<p>${opinion.opinion}</p>";
                }
            }else{
                userHtml+='<input type="hidden" name="id" value="${opinion.id}">'
                    +'<p><b>${opinion.commentatorName}</b>&nbsp;&nbsp;<fmt:formatDate value="${opinion.commentTime}" pattern="yyyy-MM-dd hh:mm:ss"/></p>'
                    +'<textarea class="easyui-text" style="min-height: 50px;width:80%" name="opinion">${opinion.opinion}</textarea>';
            }
        </c:forEach>
        $('#workPlanTodo_pz').append(html);
        $('#workPlanTodo_pz').append(userHtml);
    })

    function updateTodo(){
        var id=$('#workPlanTodo_form [name=id]').val();
        var opinion=$('#workPlanTodo_form [name=opinion]').val();
        console.log(id)
        console.log(opinion)
        $.ajax({
            url:'${ctxPath}/workComment/updateOpinion',
            data:{id:id,opinion:opinion},
            type:'post',
            dataType:'json',
            success:function(data){
                if(data.success){
                    parent.refreshTodo();
                    dialog.dialog('close');
                }
            }

        })
    }
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false" title="" style="overflow-x:hidden;overflow-y: auto;padding: 3px;">
        <table class="grid" id="workPlanTodo_form">
            <tr>
                </td>
                <td><b>标题</b></td>
                <td colspan="3">
                    ${workPlan.name}
                </td>
            </tr>
            <tr>
                <td><b>计划类别</b></td>
                <td>
                    ${workPlan.planBelongTo}
                </td>
                <td><b>类型</b></td>
                <td>
                    <c:if test="${workPlan.type==0}">
                        日计划
                    </c:if>
                    <c:if test="${workPlan.type==1}">
                        周计划
                    </c:if>
                    <c:if test="${workPlan.type==2}">
                        月计划
                    </c:if>
                    <c:if test="${workPlan.type==3}">
                        季度计划
                    </c:if>
                    <c:if test="${workPlan.type==4}">
                        年度计划
                    </c:if>
                </td>
            </tr>
            <tr>
                <td><b>计划内容</b></td>
                <td colspan="3">
                    ${workPlan.content}
                </td>
            </tr>
            <tr>
                <td><b>附件</b></td>
                <td colspan="3">
                    <c:forEach var="attach"
                               items="${workPlan.attachList}">
                    <p>${attach.name}
                        <c:if test="${attach.type=='pdf'}">
                        <a style='margin-left: 20px;'
                           href='/jsp/pdfjs/web/viewer.html?file=/pdfView/view?name%3d${attach.id}'
                           target='_blank'>在线预览</a>
                        </c:if>
                        <a style='margin-left: 20px;' href='javascript:void(0)'
                           onClick='downloadAttach("${attach.id}")'>下载</a>
                        </c:forEach>
                </td></tr>
            <tr>
                <td><b>主送人</b></td>
                <td colspan="3">${workPlan.commentatorNames}</td>
            </tr>
            <tr>
                <td><b>抄送人</b></td>
                <td colspan="3">${workPlan.userNameCcs}</td>
            </tr>
            <tr>
                <td><b>批注</b></td>
                <td colspan="3" id="workPlanTodo_pz">

                </td>
            </tr>
            <tr>
                <td><b>提交人</b></td>
                <td>${workPlan.userName}</td>
                <td><b>提交时间</b></td>
                <td><fmt:formatDate value="${workPlan.saveDate}" pattern="yyyy-MM-dd"/> </td>
            </tr>
        </table>
    </div>
</div>